<?php
/**
 * Created by PhpStorm.
 * User: LiuJiaJun
 * Date: 2019/1/21
 * Time: 11:10
 */

namespace api\storage\model;


use think\Model;

class CarModel extends Model
{
    protected $table = 'iwh_car';
    protected $pk = 'uuid';


    /**
     * 查找小车
     *
     * @param $carId
     * @return array|false|\PDOStatement|string|Model
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function findByCarId($carId){
        return $this->where('car_id',$carId)->find();
    }

    /**
     * 查找carId对应的uuid
     *
     * @param $carId
     * @return mixed
     */
    public function findCarUuid($carId){
        return $this->where('car_id',$carId)->value('uuid');
    }

    /**
     * 更新status字段
     *
     * @param $carId
     * @param int $status
     * @return false|int
     */
    public function updateStats($carId,$status = 0){
        return $this->isUpdate(true)->save(['status'=>$status],['car_id'=>$carId]);
    }
}